#!/usr/bin/env node

const fs=require('fs'),
      src=process.argv[2],
      dst=process.argv[3];

try{

  let len=fs.statSync(src).size;
  let buf=Buffer.alloc(len);
  let fid=fs.openSync(src,'r');

  //复制文件内容
  //let stm = fs.createReadStream(src).pipe(fs.createWriteStream(dst));
  var file=fs.readSync(fid,buf,0,len,0);

  fs.writeFileSync(dst,file);

  //复制文件权限
  fs.chmodSync(dst,fs.statSync(src).mode);
 
  fs.closeSync(fid);
}catch(e){
  console.error(e.message);
}


